<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<style type="text/css">
#itemDetail .box p>label>span {
	display: inline-block;
	width: 50px;
	text-align: right;
}

#itemDetail input[type='text'], #itemDetail select{
	width: 125px
}

#itemDetail  .formBox {
	padding: 0;
}

</style>
<div class="modal fade" id="itemDetail" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document" style="width: 940px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">物品批次信息</h4>
			</div>
				<div class="box modal-body">
					<form id="searchItemForm" class="form">
					<p>
						<label>批次号</label>
						<input type="text" class="form-control" name="batchNumber"></input>
						<label>仓库</label>
						<select name="warehouseManagementID" class="form-control select">
							<option value="">全部</option>
							<c:forEach items="${warehouseList }" var="war">
								<option value="${war.warehousemanagementid }" <c:if test="${validityWarningPage.warehouseManagementID==war.warehousemanagementid}">selected</c:if>>${war.warehousename }</option>
							</c:forEach>
						</select>
						<input class="btn btn1" type="button" value="搜索" onclick="initItemTable();" >
					</p>
					</form>
					<table id="add_item_table"></table>
				</div>
			<div class="red" id="add_purchase_request_item_msg" style="text-align:center;"></div>
			<div class="modal-footer">
				<button type="button" class="btn btn2" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>
</div>
<script>

var searchData="";
var itemId="";
function showItemDetail(id){
	itemId=id;
	initItemTable();
	$('#itemDetail').modal('show');
}


function initItemTable(){
	var columns = [ {
		field : "batchNumber",
		title : "批次号"
	}, {
		field : "number",
		title : "数量"
	}, {
		field : "purchasingUnit",
		title : "单位"
	},{
		field : "warehouseName",
		title : "仓库"
	},{
		field : "expiryDate",
		title : "有效期",        
		formatter:function(value,row,index){
			var date=new Date();
			date.setTime(value);
			return date.format('yyyy-MM-dd');
        }
	}];
	searchData=$("#searchItemForm").serialize();
	searchData=searchData+"&itemInformationID="+itemId;
   	$("#add_item_table").bootstrapTable("destroy");
	$("#add_item_table").bootstrapTable({
   		columns: columns,
   		data: [], 
   		pageSize: 5, 
   		pageList: [5,10],
   		pagination: true,
		clickToSelect: true,
		uniqueId: "id",
		sidePagination: 'server',
		pageNumber: 1,
		queryParams: function (params) {
			var currentPage=params.offset/params.limit+1;
			var str=searchData+"&currentPage="+currentPage+"&pageSize="+params.limit;
		    return str;
		},
		url: '<%=basePath %>inventory/getAllBatchInfoById'
   	});
}
</script>